/*
 * templateobject.h
 *
 *  Created on: Oct 27, 2009
 *      Author: price
 */

#ifndef TEMPLATEOBJECT_H_
#define TEMPLATEOBJECT_H_

#include <string>
#include <fstream>
#include <string.h>
#include <sstream>
#include "templatetypes.h"

namespace templatipus {

enum TObjectType {
	NO_TYPE,
	NUMBER_TYPE,
	STRING_UTF8_TYPE,
	STRING_UNICODE_TYPE,
	MAP_TYPE,
	ARRAY_TYPE,
	BOOLEAN_TYPE,
	NULL_TYPE,
	FUNCTION_TYPE
};

class TemplateObject {
public:

	TemplateObject();
	TemplateObject(const TemplateObject &other);
	TemplateObject(const tbool &rhs);
	TemplateObject(const int8 &rhs);
	TemplateObject(const int16 &rhs);
	TemplateObject(const int32 &rhs);
	TemplateObject(const int64 &rhs);
	TemplateObject(const float32 &rhs);
	TemplateObject(const float64 &rhs);
	TemplateObject(const utf8Ptr rhs);
	TemplateObject(const unicodePtr rhs);
	TemplateObject(const std::wstring& rhs);
	TemplateObject(const std::string& rhs);

	virtual ~TemplateObject();

	//base methods
	virtual TObjectType getType() const;

	//operations
	virtual const TemplateObject& operator ++();
	virtual const TemplateObject& operator --();
	virtual const TemplateObject& operator +=(const TemplateObject &other);
	virtual const TemplateObject& operator -=(const TemplateObject &other);
	virtual const TemplateObject& operator *=(const TemplateObject &other);
	virtual const TemplateObject& operator /=(const TemplateObject &other);
	virtual const TemplateObject& operator %=(const TemplateObject &other);
	virtual const TemplateObject& operator &=(const TemplateObject &other);
	virtual const TemplateObject& operator |=(const TemplateObject &other);

	//assigning values
	virtual TemplateObject& operator=(const TemplateObject &other);
	virtual TemplateObject& operator=(const int8 &other);
	virtual TemplateObject& operator=(const int16 &other);
	virtual TemplateObject& operator=(const int32 &other);
	virtual TemplateObject& operator=(const int64 &other);
	virtual TemplateObject& operator=(const float32 &other);
	virtual TemplateObject& operator=(const float64 &other);
	virtual TemplateObject& operator=(const std::wstring& other);
	virtual TemplateObject& operator=(const std::string& other);
	virtual TemplateObject& operator=(const utf8Ptr other);
	virtual TemplateObject& operator=(const unicodePtr other);

	//comparison
	virtual tbool operator ==(const TemplateObject &other) const;
	virtual tbool operator !=(const TemplateObject &other) const;
	virtual tbool operator >(const TemplateObject &other) const;
	virtual tbool operator <(const TemplateObject &other) const;
	virtual tbool operator <=(const TemplateObject &other) const;
	virtual tbool operator >=(const TemplateObject &other) const;

	virtual tbool operator &&(const TemplateObject &other) const;
	virtual tbool operator ||(const TemplateObject &other) const;

	//String stuff
	virtual operator std::string() const;
	virtual operator std::wstring() const;

	//Conversion operators
	//Number
	virtual operator tbool() const;
	virtual operator int8() const;
	virtual operator uint8() const;
	virtual operator int16() const;
	virtual operator uint16() const;
	virtual operator int32() const;
	virtual operator uint32() const;
	virtual operator int64() const;
	virtual operator uint64() const;
	virtual operator float32() const;
	virtual operator float64() const;

	virtual TemplateObject * newInstance() const{
		return new TemplateObject();
	}
	// Inner members
	// http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/overl.htm
	/*
	 virtual TemplateObject operator [](const uint32 index);
	 virtual TemplateObject operator [](const utf8Ptr key);
	 virtual TemplateObject operator [](const unicodePtr key);
	 virtual TemplateObject operator ()(const TemplateObject &params);


	 //Streaming operators
	 friend std::istream& operator >>(std::istream&, TemplateObject&);
	 friend std::ostream& operator <<(std::ostream&, const TemplateObject&);

	 */
};

}

#endif /* TEMPLATEOBJECT_H_ */
